package com.yunxun.coinmessage.dao;

import com.yunxun.coinmessage.entity.Coin;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface CoinDao {
    @Insert("insert into coin(cname,english_name,ccode,curl,cnotice_place,cintro) values(#{cname},#{english_name},#{ccode},#{curl},#{cnotice_place},#{cintro})")
    Integer addCoin(Coin coin);

    @Select("select * from coin where status=1 ")
    List<Coin> queryAll();
    //分页查询
    @Select("select * from coin where status=1 limit #{start},#{limit}")
    List<Coin> queryByPage(@Param("start") int start,@Param("limit") int limit);

    @Select("select * from coin where cid=#{cid}")
    Coin queryById(Integer cid);
    @Update("update coin set status=0 where cid=#{cid}")
    Integer deleteById(Integer cid);
    @Update("update coin set cname=#{cname},ccode=#{ccode},curl=#{curl},cnotice_place=#{cnotice_place},cintro=#{cintro} where cid=#{cid} " )
    Integer updateById(Coin coin);
    @Select("select count(*) from coin where status=1")
    Integer queryTotal();

    @Select("select * from coin where cname=#{cname}")
    List<Coin> queryByName(String name);
}
